import 'dart:typed_data';

class Book {
  final String name;
  final String type; // txt or epub
  final String? path; // 非web端本地路径
  final String? contentBase64; // 仅web端txt
  final bool isTemp; // web端epub临时导入

  Book({
    required this.name,
    required this.type,
    this.path,
    this.contentBase64,
    this.isTemp = false,
  });

  Map<String, dynamic> toJson() => {
    'name': name,
    'type': type,
    'path': path,
    'contentBase64': contentBase64,
    'isTemp': isTemp,
  };

  factory Book.fromJson(Map<String, dynamic> json) => Book(
    name: json['name'],
    type: json['type'],
    path: json['path'],
    contentBase64: json['contentBase64'],
    isTemp: json['isTemp'] ?? false,
  );
}

class Chapter {
  final String title;
  final String content;
  Chapter({required this.title, required this.content});
}

class ChapterInfo {
  final String title;
  final int start;
  final int end;
  ChapterInfo({required this.title, required this.start, required this.end});
}

class EpubChapter {
  final String title;
  final String? textContent;
  final List<Uint8List>? images;
  EpubChapter({required this.title, this.textContent, this.images});
} 